package cn.maszy.service.impl.systemsetting;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.maszy.common.DateUtils;
import cn.maszy.dao.investment.B_T_Ufp_WorkMapper;
import cn.maszy.dao.systemsetting.C_V_Sys_LoginInfoMapper;
import cn.maszy.model.investment.B_T_Ufp_Work;
import cn.maszy.model.investment.B_T_Ufp_WorkExample;
import cn.maszy.model.systemsetting.C_V_Sys_LoginInfo;
import cn.maszy.model.systemsetting.C_V_Sys_LoginInfoExample;
import cn.maszy.model.systemsetting.C_V_Sys_LoginInfoExample.Criteria;
import cn.maszy.service.systemsetting.C_V_Sys_LoginInfoService;
@Service
public class C_V_Sys_LoginInfoServiceImpl implements C_V_Sys_LoginInfoService {
	@Autowired
	private C_V_Sys_LoginInfoMapper c_V_Sys_LoginInfoMapper;
	@Autowired
	private B_T_Ufp_WorkMapper b_T_Ufp_WorkMapper; 
	/**
	 * 登录
	 */
	public  C_V_Sys_LoginInfo  loginQuery(C_V_Sys_LoginInfo c_V_Sys_LoginInfo) {
		C_V_Sys_LoginInfoExample example=new C_V_Sys_LoginInfoExample();
		Criteria criteria = example.createCriteria();
		if(c_V_Sys_LoginInfo!=null){
			if(c_V_Sys_LoginInfo.getLoginName()!=null && !"".equals(c_V_Sys_LoginInfo.getLoginName())){
				criteria.andLoginNameEqualTo(c_V_Sys_LoginInfo.getLoginName()).andLoginPasswordEqualTo(c_V_Sys_LoginInfo.getLoginPassword());
			}
		}
		example.or(criteria);
		List<C_V_Sys_LoginInfo> list_C_V_Sys_LoginInfo = c_V_Sys_LoginInfoMapper.selectByExample(example);
		if(list_C_V_Sys_LoginInfo.size() >0){
			c_V_Sys_LoginInfo =	list_C_V_Sys_LoginInfo.get(0);
		}else{
			c_V_Sys_LoginInfo = new C_V_Sys_LoginInfo();
		}
		return c_V_Sys_LoginInfo; //有此用户
	}
	public B_T_Ufp_Work selectOne(String uuid) {
		B_T_Ufp_WorkExample example = new B_T_Ufp_WorkExample();
		example.or().andWorktimeEqualTo(DateUtils.now()).andWorkidEqualTo(uuid);
		List<B_T_Ufp_Work> record=b_T_Ufp_WorkMapper.selectByExample(example);
		B_T_Ufp_Work b_T_Ufp_Work = new B_T_Ufp_Work();
		if(record.size()>0){
			b_T_Ufp_Work = record.get(0);
		}else{
		}
		return b_T_Ufp_Work;
	}
}
